package com.glink.mydemo;

import android.app.Activity;
import android.os.Bundle;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.baize.glinkad.bean.ads.InterstitialAD;
import com.baize.glinkad.bean.listener.InterstitialListener;
import com.baize.glinkad.manager.GLinkADManager;
import com.baize.glinkad.utils.ADLogHelper;


public class InterstitialActivity extends Activity {
    private Button show_interstitial;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_interstitial);
        show_interstitial = (Button) findViewById(R.id.show_interstitial);

        final InterstitialAD interstitial = new InterstitialAD(InterstitialActivity.this,"插屏_Test");
        interstitial.init();
        interstitial.setInterstitialListener(new InterstitialListener() {
            @Override
            public void onReady() {
                ADLogHelper.info("onReady ");
            }

            @Override
            public void onFail(String code, String msg) {
                ADLogHelper.info("onFail： code: " + code + "   msg:" + msg);
            }

            @Override
            public void onClicked() {
                ADLogHelper.info("onClicked");
            }

            @Override
            public void onShow() {
                ADLogHelper.info("onShow");
            }

            @Override
            public void onClose() {
                ADLogHelper.info("onClose");
            }


        });
        interstitial.load();

        show_interstitial.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (interstitial.isReady()){
                    interstitial.show();
                }

            }
        });

    }

    @Override
    protected void onDestroy() {
        GLinkADManager.onDestory(this);
        super.onDestroy();

    }

    @Override
    protected void onResume() {
        GLinkADManager.onResume(this);
        super.onResume();

    }

    @Override
    protected void onPause() {
        GLinkADManager.onPause(this);
        super.onPause();

    }
}
